package com.lycx.businessmanager.controller.systemManager;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.lycx.businessmanager.controller.BaseController;
import com.lycx.businessmanager.model.Dictionary;
import com.lycx.businessmanager.service.IDictionaryService;

/**
 * 字典controller
 * 
 * @author lambert
 * 
 */

@Controller
@RequestMapping("/dictionary")
public class DictionaryController extends BaseController{
	@SuppressWarnings("unused")
	private static Logger log = Logger.getLogger(DictionaryController.class);
	private IDictionaryService dictionaryService;

	public void setDictionaryService(IDictionaryService dictionaryService) {
		this.dictionaryService = dictionaryService;
	}

	@RequestMapping(value = "/list")
	public ModelAndView query(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mv = new ModelAndView("/system/dictionary/list");
		return mv;
	}
	
	@RequestMapping(value = "/getList",method = RequestMethod.POST)
	@ResponseBody
	public List<Dictionary> getList(Dictionary dictionary){
		List<Dictionary> dictList = null;
		
	    dictList = dictionaryService.select(dictionary);
        return dictList;
	}
	
	@RequestMapping(value = "/add",method = RequestMethod.POST)
	@ResponseBody
	public String add(Dictionary dictionary){
		String result = null;
		if(dictionary!=null){
	        result = dictionaryService.add(dictionary);
		}
        return result;
	}
	
	@RequestMapping(value = "/del",method = RequestMethod.POST)
	@ResponseBody
	public String del(int ids[]){
		String result = null;
		result = dictionaryService.del(ids);
		return result;
	}
	
	@RequestMapping(value = "/mod",method = RequestMethod.POST)
	@ResponseBody
	public String mod(Dictionary dictionary){
		String result = null;
		if(dictionary!=null){
			result = dictionaryService.mod(dictionary);
		}
		return result;
	}
	
	@RequestMapping(value = "/getDictTypeList",method = RequestMethod.POST)
	@ResponseBody
	public List<Dictionary> getDictTypeList(Dictionary dictionary){
		List<Dictionary> dictTypeList = null;
		dictTypeList = dictionaryService.getDictTypeList(dictionary);
        return dictTypeList;
	}
}
